var mysql      = require('mysql');
var pool  = mysql.createPool({
    connectionLimit: 10,
    host: 'localhost',
    user: 'root',
    password: 'peng123',
    database: 'js_test'
});
exports.query= function(sql, params) {
    return new Promise((resolve, reject) => {
        pool.getConnection(function(err, connection) {
            if (err) {
                throw err; // not connected!
            }; 
           
            // Use the connection
            connection.query(sql, function (error, results, fields) {
              // When done with the connection, release it.
                console.log(sql)
              connection.release();
              // Handle error after the release.
                if (error) {
                  return reject(error)
                };
                resolve(results)
            });
          });
    })
}
